package com.jk.smartelderlycare.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jk.smartelderlycare.dao.SysFieldMapper;
import com.jk.smartelderlycare.dto.SysField;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.service.SysFieldService;
import com.jk.smartelderlycare.utils.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author hhk
 * @version 1.0
 * @ClassName SysFieldServiceImpl
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/11/18 14:19
 */
@Service
public class SysFieldServiceImpl implements SysFieldService {
    @Autowired
    public SysFieldMapper sysFieldMapper;
    /**
     * @description: 字段后端分页查询
     * @param: [sysField, pageNum, pageSize]
     * @return: com.jk.smartelderlycare.pojo.PagedResponse<com.jk.smartelderlycare.dto.SysField>
     * @author hhk
     * @date: 2024/11/18 14:23
     */
    @Override
    public PagedResponse<SysField> findSysFieldPaginationList(SysField sysField, Integer pageNum, Integer pageSize) {
        Page<SysField> page = new Page<>(pageNum,pageSize);
       IPage<SysField> PageList = sysFieldMapper.findSysFieldPaginationList(page,sysField);
        return PaginationUtil.getPagedResponse(PageList.getRecords(),pageNum,pageSize,PageList.getTotal());
    }
    /**
     * @description: 新增
     * @param: [sysField]
     * @return: void
     * @author hhk
     * @date: 2024/11/18 14:26
     */
    @Override
    public void addSysField(SysField sysField) {
        sysFieldMapper.insert(sysField);
    }
    /**
     * @description: 根据id删除有一条数据
     * @param: [fieldId]
     * @return: void
     * @author hhk
     * @date: 2024/11/18 14:27
     */
    @Override
    public void deleteSysFieldByFieldId(Long fieldId) {
        sysFieldMapper.deleteById(fieldId);
    }
    /**
     * @description: 根据id回显一条数据
     * @param: [fieldId]
     * @return: com.jk.smartelderlycare.dto.SysField
     * @author hhk
     * @date: 2024/11/18 14:27
     */
    @Override
    public SysField findSysFieldById(Long fieldId) {
        return sysFieldMapper.selectById(fieldId);
    }
    /**
     * @description: 修改
     * @param: [sysField]
     * @return: void
     * @author hhk
     * @date: 2024/11/18 14:28
     */
    @Override
    public void updataSysField(SysField sysField) {
        sysFieldMapper.updateById(sysField);
    }
    /**
     * @description: 修改状态
     * @param: [sysField]
     * @return: void
     * @author hhk
     * @date: 2024/11/18 14:28
     */
    @Override
    public void updateStatus(SysField sysField) {
        sysFieldMapper.updateStatus(sysField);
    }
}
